package servicesImp.log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import services.log.TableEditLogServices;
import util.JsonUtil;
import wt.entity.log.TableEditLogWithBLOBs;

import java.util.List;

/**
 * Created by Administrator on 2017/10/14.
 */



public class InsertTableEditLogListThread extends Thread {
private  static Logger log= LoggerFactory.getLogger(InsertTableEditLogListThread.class);
    List<Object> data;
    TableEditLogServices tableEditLogServices;
    TableEditLogWithBLOBs tableEditLogWithBLOBs;
    public InsertTableEditLogListThread(List<Object> data, TableEditLogServices tableEditLogServices, TableEditLogWithBLOBs tableEditLogWithBLOBs) {
        this.data=data;
        this.tableEditLogServices=tableEditLogServices;
        this.tableEditLogWithBLOBs=tableEditLogWithBLOBs;
    }
    public void run() {
        if (data!=null){
            for (int i = 0;i <data.size() ; i++) {
                try {
                    tableEditLogWithBLOBs.setId(null);
                    tableEditLogWithBLOBs.setTableData(JsonUtil.obj2Json(data.get(i)));
                    tableEditLogServices.insertSelective(tableEditLogWithBLOBs);
                } catch (Exception e) {
                    log.error("【Manual】=>{}",e.getMessage());
                    log.error("【Manual】=>一条日志记录失败:{}", JsonUtil.obj2Json(tableEditLogWithBLOBs));
                }
            }
        }
    }
}
